{template 'header'}
<!--当前位置-->
<div class="location layout960">
	当前位置: <a href="{SITE_URL}">首页</a>&nbsp; »&nbsp; <a href="{SITE_URL}owncard/index.php">车主金卡</a>
</div>
<!--当前位置 end-->
<!--主体部分-->
	{if $action == ''|| $action == 'edit'}
	<!--主体部分-->
	<div class="card-body bd layout960">
		<p class="card-process first"></p>
		<h2 class="card-hd">填写订购信息</h2>
		<form id="card-form" action="{SITE_URL}owncard/buy.php" method="post">
			<input type="hidden" name="action" value="{$action}">
			<input type="hidden" name="itemid" value="{$itemid}">
			<table class="form-default">
				<tr>
					<th width="80">收货人：</th>
					<td width="500">
						<input class="easyui-validatebox" title="请输入收货人姓名" type="text" size="18"  name="post[truename]" value="{$truename}">
						<label for="card-num">&nbsp;&nbsp;数量：</label>
						<input class="easyui-validatebox" id="card-num" title="请输入购买数量" type="text" size="1" name="post[buynum]" {if $buynum}value="{$buynum}"{else}value="1"{/if}><label for="card-num">&nbsp;张</label>
					</td>
				</tr>
				<tr>
					<th>所在地区：</th>
					<td><div id="area" class="area-content">
						<input type="hidden" id="area-field" name="post[areaid]" />
					</div>
					</td>
				</tr>
				<tr>
					<th>详细地址：</th>
					<td><input class="easyui-validatebox" title="请输入详细地址" type="text" size="40" name="post[address]"  value="{$address}"></td>
				</tr>
				<tr>
					<th>联系电话：</th>
					<td><input type="text" size="40" name="post[telephone]" value="{$telephone}" ></td>
				</tr>
				<tr>
					<th>手机号码：</th>
					<td><input id="mobile" title="请输入手机号码" class="easyui-validatebox" type="text" size="40" name="post[mobile]" value="{$mobile}"></td>
				</tr>
				<tr>
					<th>电子邮件：</th>
					<td><input id="email" title="请输入邮箱" class="easyui-validatebox" type="text" size="40" name="post[email]" value="{$email}"></td>
				</tr>
				<tr>
					<th>附言：</th>
					<td><textarea  name="post[note]" >{$note}</textarea></td>
				</tr>
				<tr>
					<td colspan="2"><button id="card-sbt" type="submit" class="main-log-btn" name="submit">提交订购信息</button></td>
				</tr>
			</table>
		</form>
	</div>
	{/if}
	{if $action == 'pay'}
	<!--主体部分-->
	<div class="card-body bd layout960">
		<p class="card-process second"></p>
		<h2 class="card-hd">核对订购信息<a href="{SITE_URL}owncard/buy.php?action=edit&itemid={$itemid}" title="修改">[修改]</a></h2>
		<form action="{SITE_URL}owncard/buy.php" method="post" {if $payable}target="_blank"{/if}>
			<input type="hidden" name="action" value="{$action}">
			<input type="hidden" name="itemid" value="{$itemid}">
			<table class="form-default">
				<tr>
					<th width="80">收货人：</th>
					<td width="350">{$truename}</td>
				</tr>
				<tr>
					<th>购买数量：</th>
					<td>{$buynum}张</td>
				</tr>
				<tr>
					<th>所在地区：</th>
					<td>{area_pos($areaid,' ','','3421')}</td>
				</tr>
				<tr>
					<th>详细地址：</th>
					<td>{$address}</td>
				</tr>
				<tr>
					<th>联系电话：</th>
					<td>{$telephone}</td>
				</tr>
				<tr>
					<th>手机号码：</th>
					<td>{$mobile}</td>
				</tr>
				<tr>
					<th>电子邮件：</th>
					<td>{$email}</td>
				</tr>
				<tr>
					<th>附言：</th>
					<td><p class="card-postscript">{$note}</p></td>
				</tr>
				<tr>
					<td colspan="2" align="right">
						<table class="card-total">
							<tr>
								<th width="85">应付总额：</th>
								<td width="150"><span class="corange">¥<strong>{number_format($total,2)}</strong></span></td>
							</tr>
							<tr>
								<th>讯都账户余额：</th>
								<td><span class="corange">¥<strong>{$userinfo['money']}</strong></span></td>
							</tr>
							{if $payable}
							<tr class="">
								<td colspan="2" >您的讯都账户余额不足，还需支付<span class="pay cred">¥{$payable}</span>元</td>
							</tr>
							{/if}
						</table>
					</td>
				</tr>
				{if $payable}
				<tr>
					<td colspan="2" align="right">
						<table class="card-total">
							<tr>
								<td width="65">支付平台：</td>
								<td width="150">
									{php $i=0;}
									{loop $PAY $k=>$v}
									{if $v[enable]}
									<p  style="width: 120px">
										<input class="fn-left nobd mr5 mt10"  type="radio" name="bank" value="{$k}" id="{$k}"{if $i==0} checked{/if}/>
										<label for="{$k}"><img src="{SITE_URL}file/image/logo_{$k}.gif" alt=""/></label>
									</p>
									{php $i=1;}
									{/if}
									{/loop}
									{if $i==0}
									<br/>抱歉，系统未设置支付平台，暂时无法在线充值
									{/if}
								</td>
							</tr>
						</table>
					</td>
				</tr>
				{/if}
				<tr>
					<td colspan="2"><button {if $payable}id="J_ConfirmBuy"{/if} type="submit" class="main-log-btn" name="submit">确认付款订购</button></td>
				</tr>
			</table>
		</form>
        <div id="J_PatDialog" class="pay-dialog fn-hide">
            <div class="dialog-bar"><a class="J_CloseDialog" href="javascript:void(0)" title="关闭">关闭</a></div>
            <p class="hd"><i class="warn"></i>请您在新打开的页面上完成付款</p>
            <p>付款完成前请不要关闭此窗口。</p>
            <p>完成付款后请根据您的情况点击下面按钮：</p>
            <div class="buy-btns fn-clear">
                <a class="J_CloseDialog pay-btn" href="javascript:location.reload();">已完成付款</a>
                <a class="J_CloseDialog pay-btn" href="javascript:void(0)">其他支付方式</a>
            </div>
        </div>
	</div>
        <script>
            seajs.use(['$'],function($){
                $(".J_CloseDialog").click(function(){
                    $("#J_PatDialog").hide();
                });
                $("#J_ConfirmBuy").click(function(){
                    $("#J_PatDialog").show();
                });
            });
        </script>
	<!--主体部分end-->
{/if}
{if $action == 'success'}
<!--主体部分-->
<div class="card-body bd layout960">
	<p class="card-process third"></p>
	<h2 class="card-hd"></h2>
	<p class="tip-status {if $fail}fail{else}success{/if}">{$message}</p>
	<ul class="card-suc ul-gray graydot c666">
		<li>付款金额：{if $money || $xdmoney}￥{php echo $money+$xdmoney}元{else}<span class="cred">订购失败</span>{/if}</li>
		<li class="fn-clear">
			<span class="fn-left">在线客服：</span>
			<a class="icon-consult-online fn-left" href="{SITE_URL}ask/online.php" target="_blank" title="点击咨询"></a>
		</li>
		<li>服务电话：{$DT[telephone]}</li>
	</ul>
	<div class="hd-graybg">
		<h2>推荐商家信息</h2>
	</div>
	<div id="card-img-scroll" class="index-img-scroll fn-left fn-clear">
		<a class="pre" href="javascript:void(0);"></a>
		<div class="img-scroll-list fn-clear">
			<ul class="fn-clear">
				{loop $indexData $k $business}
				{php $title = $business['shopname'];}
				{php if ($business['nickname']):}
				{php $title .= '('.$business['nickname'].')'}
				{php endif;}
				<li>
					<a class="img" href="{url('shop/show', 'itemid='.$business['itemid'])}" target="_blank" title="{$title}"><img src="{$business['thumb']}" alt="{$title}"></a>
					<a class="text-ellipsis" href="{url('shop/show', 'itemid='.$business['itemid'])}" title="{$title}">{$title}</a>
				</li>
				{/loop}
			</ul>
		</div>
		<a class="next" href="javascript:void(0);"></a>
	</div>
</div>
<script type="text/javascript">
    seajs.use(['mod-imgScroll'],function(ImgScroll){
        var cardImg = new ImgScroll("#card-img-scroll", 8);
        cardImg.slide();
    })
</script>
<!--主体部分end-->
{/if}
<script type="text/javascript">
	seajs.use(['mod-area','easyui','easyui-css',,'easyui-icon-css'], function(area){
		area.init("{PUBLIC_URL}data/area.json");
		var config = {
			'conId' : "area",
			'step' : 4,
			'name1' : "location_link[prov]",
			'name2' : "location_link[city]",
			'name3' : "location_link[town]",
			'name4' : "location_link[vell]"
		};
		<!--{if $areaid}-->
		config.selValue = {$AREA[$areaid][fullcode]};
		<!--{/if}-->
		area.makeSelect(config);
		area.changeArea("area");

		function validateArea(){
			if($("#area-field").val()==0 || $("#area-field").val()==3421 ){
				$("#area").find("select").addClass("validatebox-invalid")
				return false;
			}else{
				$("#area").find("select").removeClass("validatebox-invalid")
			}
		}
		$("#card-sbt").click(function(){
			$(".easyui-validatebox").each(function(){
				var title = $(this).attr("title");
				$(this).validatebox({
					required:true,
					missingMessage:title
				});
			});
			$('#mobile').validatebox({
				validType:'mobile["value"]'
			});
			$('#email').validatebox({
				validType:'email["value"]'
			});

			validateArea();
			$("#area").find("select").change(function(){
				validateArea();
			});

			<!--{if $_username}-->
			$('#card-form').on('submit', function(){
				return $("#card-form").form('validate');
			});
			<!--{/if}-->
		});

	});
</script>
{template 'footer'}